package com.zero.system.service.Impl;

import com.zero.system.entity.Flight;
import com.zero.system.mapper.FlightMapper;
import com.zero.system.service.FlightService;
import com.zero.system.util.PageBean;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;


@Service
public class FlightServiceImpl implements FlightService {
    @Resource
    private FlightMapper flightMapper;

    @Override
    public PageBean<Flight> queryPage(Map<String, Object> paramMap) {
        PageBean<Flight> pageBean = new PageBean<>((Integer) paramMap.get("pageno"),(Integer) paramMap.get("pagesize"));
        Integer startIndex = pageBean.getStartIndex();
        paramMap.put("startIndex",startIndex);
        List<Flight> datas = flightMapper.queryList(paramMap);
        pageBean.setDatas(datas);
        Integer totalsize = flightMapper.getCount(paramMap);
        pageBean.setTotalsize(totalsize);
        return pageBean;
    }

    @Override
    public Integer getCount(Map<String, Object> paramMap) {
        return flightMapper.getCount(paramMap);
    }

    @Override
    public int add(Flight flight) {
        return flightMapper.add(flight);
    }

    @Override
    public Flight findById(Integer id) {
        return flightMapper.findById(id);
    }

    @Override
    public int delete(List<Integer> ids) {
        return flightMapper.delete(ids);
    }

    @Override
    public int update(Flight flight) {
        return flightMapper.update(flight);
    }

    @Override
    public Flight findByFlightNo(String flightNo) {
        return flightMapper.findByFlightNo(flightNo);
    }

    @Override
    public List<Flight> findAll() {
        return flightMapper.findAll();
    }

    @Override
    public List<Flight> findByCondition(String startPlace, String endPlace, Date startDate, Date day1) {
        return flightMapper.findByCondition(startPlace,endPlace,startDate,day1);
    }
}
